package com.google.code.maven.plugin.http.client.transformer;

import java.io.BufferedReader;
import java.io.IOException;

import org.apache.http.HttpEntity;
import org.apache.maven.plugin.MojoExecutionException;

/**
 * {@link HttpEntity} {@link Transformer} returning the response content as a {@link BufferedReader}
 * 
 * @author Nadim Benabdenbi
 * @version 1.0
 * @since JDK1.6
 * 
 * @see HttpEntity
 * @see BufferedReader
 * @see AbstractHttpEntityTransformer
 */
public class HttpEntityToContentReader extends AbstractHttpEntityTransformer<BufferedReader> {
	
	/**
	 * 
	 */
	@Override
	protected BufferedReader transform(HttpEntity entity) throws MojoExecutionException {
		try {
			return getContentReader(entity);
		} catch (IllegalStateException ise) {
			throw new MojoExecutionException("failed to write to system out", ise);
		} catch (IOException ioe) {
			throw new MojoExecutionException("failed to write to system out", ioe);
		}
	}
	
}
